<div style="border: 3px solid lightgreen; background-color: #eeffee; padding: 5px;">
<?php










//i) STRPC SMALL EXAMPLE

require_once '../STRPC.php';

//create class instance
$basic = new Basic();

$map = array(
	array('basic', 'echoBack',  //module name and procedure (function) name
		array(
			array('text', 'string'), //argument name and type
		),
		'string' //return value type
	),
	array('basic', 'add',		
		array(
			array('num1', 'number'),
			array('num2', 'number'),
		),
		'number'
	),
	array('basic', 'sumAndCount',		
		array(
			array('nums', 'array'),	//some arrays
		),
		'arrays'
	),
);

$rpc = new STRPC();
echo $rpc->serve($map);

class Basic
//as you see this is totally ordinary class 
//and has no STRPC specific code
{
	function echoBack($t) { return $t; }
	function add($num1, $num2) { return $num1 + $num2; }
	function sumAndCount($nums) 
	{
		$sum = 0;
		$count = 0;
		echo 'we are doing some debugging here : ';
		print_r($nums); //some "debugging" helpers
		foreach ($nums as $num)
		{
			$sum += $num;
			$count ++;
			echo "<br/>adding $num, sum now is $sum, count is $count";
		}
		echo '<br/>(result is still valid)';
		return array('sum'=>$sum, 'count'=>$count, 'nested data'=>array('works nice'=>$nums, 'and displays nice'=>$nums));
	}
}

//i) END OF EXAMPLE CODE (the rest is just some testing html)












?>
</div>
<small>this green box is serialized (Htmlized) return from STRPC call</small>
<style>body { font-family: Arial; font-size: 13px;}</style>
<h3>STRPC is very easy to debug... see below (don't forget to htmlize your input)</h3>

<div style="background-color: #fffff1;">
<b>call STRPC througth ordinary link</b>

<p>you can call echoBack with 
	<i><a href="<?php echo $_SERVER['PHP_SELF']; ?>?_call=strpc&amp;_module=basic&amp;_procedure=echoBack&amp;text=<b>hellllo</b>">this link</a></i> .
</p>

<p>you can call add with 
	<i><a href="<?php echo $_SERVER['PHP_SELF']; ?>?_call=strpc&amp;_module=basic&amp;_procedure=add&amp;num1=<i>2</i>&amp;num2=<i>3.5</i>">this link</a></i> .
</p>

<p>you can call sumAndCount with 
	<i><a href="<?php echo $_SERVER['PHP_SELF']; ?>?_call=strpc&amp;_module=basic&amp;_procedure=sumAndCount&amp;nums=<dl><dt><i>0</i></dt><dd><i>5</i></dd><dt><i>1</i></dt><dd><i>8</i></dd><dt><i>2</i></dt><dd><i>6</i></dd></dl>">this link</a></i> .
</p>

</div>

<div style="background-color: #f1ffff;">
<b>call STRPC througth ordinary form</b>

<p>echoBack <form action="" method="POST">
	<input type="hidden" name="_call" value="strpc" />
	<input type="hidden" name="_module" value="basic" />
	<input type="hidden" name="_procedure" value="echoBack" />
	<input type="text" name="text" value="<b>Hi, how are you</b>" />
	<input type="submit" value="submit" />
</form>
</p>

<p>add <form action="" method="POST">
	<input type="hidden" name="_call" value="strpc" />
	<input type="hidden" name="_module" value="basic" />
	<input type="hidden" name="_procedure" value="add" />
	<input type="text" name="num1" value="<i>9999.45</i>" />
	<input type="text" name="num2" value="<i>0.55</i>" />
	<input type="submit" value="submit" />
</form>
</p>

<p>sumAndCount <form action="" method="POST">
	<input type="hidden" name="_call" value="strpc" />
	<input type="hidden" name="_module" value="basic" />
	<input type="hidden" name="_procedure" value="sumAndCount" />
	<textarea name="nums" cols="60" rows="7" >
<dl>
	<dt><i>0</i></dt><dd><i>5</i></dd>
	<dt><i>1</i></dt><dd><i>8</i></dd>
	<dt><i>2</i></dt><dd><i>6</i></dd>
	<dt><i>3</i></dt><dd><i>12</i></dd>
	<dt><i>4</i></dt><dd><i>4</i></dd>
</dl>	
	</textarea>
	<input type="submit" value="submit" />
</form>
</p>

</div>


<div style="background-color: #fff1ff;">
We have these goals with STRPC:
<ul>
	<li>Quick and simple
		<ul>
			<li>Should be simple to write client or server even without any STRPC libraries (done)</li>
			<li>If you use STRPC library things should get totally simple - just the declaration (done in PHP)</li>
			<li>The serialisation is simple and human readable (especially in a browser ;) - Htmlize) (done)</li>
		</ul>
	</li>
	<li>Really easy to debug 
		<ul>
			<li>just open your web browser and call the server to debug it (forget about proxy listeners just to see what is going on) (done)</li>
			<li>call remote procedures simply from url lines, links or forms in a browser (done)</li>
			<li>clear and helpfull error messages (working)</li>
			<li>type checking at basic STRPC level (working)</li>
			<li>STRPC result should allow that any other content (debug messages, errors, anything) can be returned
				along with it (so notices from the server side shouldn't corrupt the info and should be passed along)
				(working)</li>
			<li>a good way to debug server side errors.. what happens if you call a STRP server that calls another STRPC
				server and that calls the third one and that third one producess a PHP notice -- that notice must
				get to the client and it must be seen that the third one produced it. (working)</li>
		</ul>
	</li>
</ul>
</div>

<small>sorry for the total lack of needed HTML elements... this isn't really a webpage.. 
its just a STRPC result with some other stuff to help you test it</small>